# !/usr/bin/env python
"""
    testing
    ~~~~~~~


    :Author: swq
    :Date: 2021/07/03 20:33 
"""
from api.config.default import DefaultConfig


class TestingConfig(DefaultConfig):

    DEBUG = False
    TESTING = True

    SQLALCHEMY_DATABASE_URI = (
        'sqlite:///:memory:'
    )

    SQLALCHEMY_ECHO = False

    CELERY_CONFIG = {
        "always_eager": True,
        "eager_propagates_exceptions": True,
        "result_backend": "cache",
        "cache_backend": "memory",
    }

    LOG_DEFAULT_CONF = {
        'version': 1,
        'disable_existing_loggers': False,

        'formatters': {
            'standard': {
                'format': '%(asctime)s %(levelname)-7s %(name)-25s %(message)s'
            },
        },

        'handlers': {
            'console': {
                'level': 'NOTSET',
                'formatter': 'standard',
                'class': 'logging.StreamHandler',
            },
        },

        # TESTING: Log to console only
        'loggers': {
            'flask.app': {
                'handlers': ['console'],
                'level': 'INFO',
                'propagate': False
            },
            'api': {
                'handlers': ['console'],
                'level': 'WARNING',
                'propagate': False
            },
        }
    }

